package entity

import "database/sql"

type UserOption func(*User)

func NewUserEntity(opts ...UserOption) UserEntity {
	user := &User{}
	user.Update(opts...)
	return user
}

func (u *User) Update(opts ...UserOption) {
	for _, opt := range opts {
		opt(u)
	}
}

func WithID(id uint) UserOption {
	return func(u *User) {
		u.ID = id
	}

}

func WithUsername(username string) UserOption {
	return func(u *User) {
		u.Username = username
	}
}

func WithName(name string) UserOption {
	return func(u *User) {
		u.Name = name
	}
}

func WithPassword(password string) UserOption {
	return func(u *User) {
		u.Password = password
	}
}

func WithRole(role uint8) UserOption {
	return func(u *User) {
		u.Role = role
	}
}

func WithDeletedAt(deletedAt sql.NullTime) UserOption {
	return func(u *User) {
		u.DeletedAt = deletedAt
	}
}
